func_list = {}
def index():
    with open("./index.html") as f:
        file_data = f.read()
    content = file_data.replace(f"{%content%}", "stock_data", 1)  # 替换1次
    return content
def center():
    with open("./center.html") as f:
        file_data = f.read()
    content = file_data.replace(f"{% content %}", "stock_data", 1)  # 替换1次
    return content
def error():
    return "404 error"
# 向路由列表中添加数据
func_list["/index.html"] = index
func_list["/center.html"] =center
# 列表中的数据
'''
{
    "/index.html": index
    "/center.html": center
}
'''

# 接口 解耦合
def application(req_path):
    # if req_path == "/index.html":
    #     return index()
    # elif req_path == "/center.html":
    #     return center()
    # else:
    #     return error()
    try:
        func = func_list[req_path]
        ret = func()
        return ret
    except Exception as e:
        return error()